package com.iplant.mes.service.po.bcm;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.pdm.service.basicenum.pdm.PDMComponentTypes;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@DBBasePO(TableName = "bcm_rule_code", Schemas = DBSchemas.MES,
        CheckName = {"ComponentType,ProductTypeID,Code"}, CodeAuto = true, CodePrefix = "BCN-{yyMM}")
public class BCMRuleCode extends BasePO {

    @DBCondition
    @DBField
    public int ComponentType = 0;

    public String ComponentTypeText = "";

    /**
     * 产品类型ID
     */
    @DBCondition
    @DBField
    public int ProductTypeID = 0;
    /**
     * 产品类型名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_producttype", tableAsName = "p1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductTypeID")
    public String ProductTypeName = "";
    /**
     * 产品类型编码
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "fpc_producttype", tableAsName = "p1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductTypeID")
    public String ProductTypeCode = "";





    /**
     * 规则字符串  暂时仅支持前缀固定 生成后续
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBField
    public String RuleString = "";
    @DBCondition
    @DBField
    public int RuleID = 0;

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("ComponentTypeText")
    public String getComponentTypeText() {
        ComponentTypeText = PDMComponentTypes.getEnumType(ComponentType).getLabel();
        return ComponentTypeText;
    }

    public void setComponentTypeText(String componentTypeText) {
        ComponentTypeText = componentTypeText;
    }

    @JsonProperty("ProductTypeID")
    public int getProductTypeID() {
        return ProductTypeID;
    }

    public void setProductTypeID(int productTypeID) {
        ProductTypeID = productTypeID;
    }

    @JsonProperty("ProductTypeName")
    public String getProductTypeName() {
        return ProductTypeName;
    }

    public void setProductTypeName(String productTypeName) {
        ProductTypeName = productTypeName;
    }

    @JsonProperty("ProductTypeCode")
    public String getProductTypeCode() {
        return ProductTypeCode;
    }

    public void setProductTypeCode(String productTypeCode) {
        ProductTypeCode = productTypeCode;
    }

    @JsonProperty("RuleString")
    public String getRuleString() {
        return RuleString;
    }

    public void setRuleString(String ruleString) {
        RuleString = ruleString;
    }

    @JsonProperty("RuleID")
    public int getRuleID() {
        return RuleID;
    }

    public void setRuleID(int ruleID) {
        RuleID = ruleID;
    }


}
